package structure.hash.basic;


public class MyHashSet<E> implements MySet<E> {
    private MyHashMap<E, Object> myHashMap = new MyHashMap<>();

    @Override
    public int size() {
        return myHashMap.size();
    }

    @Override
    public boolean isEmpty() {
        return myHashMap.isEmpty();
    }

    @Override
    public void clear() {
        myHashMap.clear();
    }

    @Override
    public boolean contains(E element) {
        return myHashMap.containsKey(element);
    }

    @Override
    public void add(E element) {
        myHashMap.put(element, null);
    }

    @Override
    public void remove(E element) {
        myHashMap.remove(element);
    }

    @Override
    public void traversal(Visitor<E> visitor) {
		myHashMap.traversal(new MyMap.Visitor<E, Object>() {
			public boolean visit(E key, Object value) {
				return visitor.visit(key);
			}
		});
    }
}
